package com.platform.service;

import com.platform.dao.CollectDao;
import com.platform.entity.CollectEntity;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 
 * 
 * @author lipengjun
 * @email 939961241@qq.com
 * @date 2017-08-13 10:41:06
 */
@Service("collectService")
public class CollectService {
	@Autowired
	private CollectDao collectDao;
	
	public int delByGoodsId(Integer userId,Integer goodsId) {
		return collectDao.del(userId, goodsId,0);
	}
	public int delByCategoryId(Integer userId,Integer categoryId) {
		return collectDao.del(userId, categoryId,1);
	}

	public int queryTotalByUserIdGoodsId(Integer userId,Integer goodsId) {
		CollectEntity collect = collectDao.existsCollect(userId, goodsId,0);
		return collect==null?0:1;
	}
	
	public int queryTotalByUserIdArticleId(Integer userId,Integer articleId) {
		CollectEntity collect = collectDao.existsCollect(userId, articleId,1);
		return collect==null?0:1;
	}
	
	public CollectEntity queryObject(Integer id){
		return collectDao.queryObject(id);
	}
	
	public List<CollectEntity> queryList(Map<String, Object> map){
		return collectDao.queryList(map);
	}
	public List<CollectEntity> queryListc(Map<String, Object> map){
		return collectDao.queryListc(map);
	}
	
	public int queryTotal(Map<String, Object> map){
		return collectDao.queryTotal(map);
	}
	
	public void save(CollectEntity collect){
		collectDao.save(collect);
	}
	
	public void update(CollectEntity collect){
		collectDao.update(collect);
	}
	
	public void delete(Integer id){
		collectDao.delete(id);
	}
	
	public void deleteBatch(Integer[] ids){
		collectDao.deleteBatch(ids);
	}
	
}
